94eaf6df75f20f79aba9b158c86d76d9f047bddd,javasrc/src/org/ccnx/ccn/KeyManager.java,KeyManager,publishKey,#ContentName#PublicKey#PublisherPublicKeyDigest#KeyLocator#CCNFlowControl#SaveType#CCNHandle#KeyManager#,743
Before Change
// Make a self-referential key locator. For now do not include the
// version.
existingLocator = new KeyLocator(new KeyName(keyName, signingKeyID));
Log.finer("Overriding constructed key locator of type KEY, making self-referential locator {0}", existingLocator);
}
}
signingKeyLocator = existingLocator;
}
// Here is where we get tricky. We might really want the key to be of a particular
// version. In general, as we use the network objects to write versioned versioned stuff,
// we might not be able to take the last component of a name, if versioned, as the version
// to use to save -- might really want <name>/<version1>/<version2>. So unless we want to
// make that impossible to achieve, we need to not have the network objects take the
// name <name>/<version1> and save to <version1> (though they read from <version1> just
// fine given the same). You always want to save to a new version, unless someone tells you
// something different from the outside.
// Come up with a contorted option. If you want to publish <version>/<version> stuff, you
// need to pass in the second version...
CCNTime keyVersion = null; // do we force a version?
Tuple<ContentName, byte []> nameAndVersion = VersioningProfile.cutTerminalVersion(keyName);
PublicKeyObject keyObject = null;
if (null != flowController) {
// If a flow controller was specified, use that
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish,
signingKeyID, signingKeyLocator, flowController);
} else {
// No flow controller given, use specified saveType.
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish, saveType,
signingKeyID, signingKeyLocator, handle);
}
if (null != nameAndVersion.second()) {
keyVersion = VersioningProfile.getVersionComponentAsTimestamp(nameAndVersion.second());
}
Log.info("publishKey: key not previously published, making new key object {0} with version {1} displayed as {2}",
keyObject.getVersionedName(), keyVersion,
((null != nameAndVersion.second()) ? ContentName.componentPrintURI(nameAndVersion.second()) : "<no version>"));
// Eventually may want to find something already published and link to it, but be simple here.
After Change
// Make a self-referential key locator. For now do not include the
// version.
existingLocator = new KeyLocator(new KeyName(keyName, signingKeyID));
if (Log.isLoggable(Log.FAC_KEYS, Level.FINER)) {
Log.finer(Log.FAC_KEYS, "Overriding constructed key locator of type KEY, making self-referential locator {0}", existingLocator);
}
}
}
signingKeyLocator = existingLocator;
}
// Here is where we get tricky. We might really want the key to be of a particular
// version. In general, as we use the network objects to write versioned versioned stuff,
// we might not be able to take the last component of a name, if versioned, as the version
// to use to save -- might really want <name>/<version1>/<version2>. So unless we want to
// make that impossible to achieve, we need to not have the network objects take the
// name <name>/<version1> and save to <version1> (though they read from <version1> just
// fine given the same). You always want to save to a new version, unless someone tells you
// something different from the outside.
// Come up with a contorted option. If you want to publish <version>/<version> stuff, you
// need to pass in the second version...
CCNTime keyVersion = null; // do we force a version?
Tuple<ContentName, byte []> nameAndVersion = VersioningProfile.cutTerminalVersion(keyName);
PublicKeyObject keyObject = null;
if (null != flowController) {
// If a flow controller was specified, use that
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish,
signingKeyID, signingKeyLocator, flowController);
} else {
// No flow controller given, use specified saveType.
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish, saveType,
signingKeyID, signingKeyLocator, handle);
}
if (null != nameAndVersion.second()) {
keyVersion = VersioningProfile.getVersionComponentAsTimestamp(nameAndVersion.second());
}
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "publishKey: key not previously published, making new key object {0} with version {1} displayed as {2}",
keyObject.getVersionedName(), keyVersion,
((null != nameAndVersion.second()) ? ContentName.componentPrintURI(nameAndVersion.second()) : "<no version>"));
}
// Eventually may want to find something already published and link to it, but be simple here.
if (!keyObject.save(keyVersion)) {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Not saving key when we thought we needed to: desired key value {0}, have key value {1}, " +
keyToPublish, new PublisherPublicKeyDigest(keyObject.publicKey()));
}
} else {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Published key {0} to name {1} with key locator {2}.", keyToPublish, keyObject.getVersionedName(), signingKeyLocator);
}
}